package net.asciiworks.filesyncr.view {
    import net.asciiworks.filesyncr.ApplicationFacade;
    import net.asciiworks.filesyncr.model.VolumeProxy;

    import flash.filesystem.StorageVolume;

    import mx.collections.ArrayCollection;

    import org.puremvc.as3.interfaces.IMediator;
    import org.puremvc.as3.interfaces.INotification;
    import org.puremvc.as3.patterns.mediator.Mediator;

    import spark.events.IndexChangeEvent;

    public class MenuMediator extends Mediator implements IMediator {
        public static const NAME:String = "MenuMediator";

        public function MenuMediator(viewComponent:Menu) {
            super(NAME, viewComponent);
        }

        override public function onRegister():void {
            menu.list.addEventListener(IndexChangeEvent.CHANGE, list_indexChangeHandler);
        }

        private function list_indexChangeHandler(event:IndexChangeEvent):void {
            sendNotification(ApplicationFacade.MENU_CHANGED, event.newIndex);
        }

        private function get menu():Menu {
            return viewComponent as Menu;
        }
    }
}